function infoPerfil(){
    var email = readCookie('k').split("#",1)[0];
    if (email)
    { // values are not empty
        $.ajax({
            type: "GET",              
            url: "cgis/consultaInfoPerfil.cgi", // URL of the Perl script
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data:"email=" + email,
            // script call was *not* successful
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
                $('div#perfilResult').text("responseText: " + XMLHttpRequest.responseText 
                    + ", textStatus: " + textStatus 
                    + ", errorThrown: " +errorThrown);
                $('div#perfilResult').addClass("error");
            }, // error
            // script call was successful
            // data contains the JSON values returned by the Perl script
            success: function(data){
                if (data.error) { // script returned error
                    $('div#perfilResult').text("data.error: "  +data.error);
                    $('div#perfilResult').addClass("error");
                        
                } // if
                else {  // login was successful

                    $('div#perfilResultNombre').text("NOMBRE: "+data.nombre);
                    $('div#perfilResultApellidos').text("APELLIDOS: "+data.apellidos);
                    $('div#perfilResultEmail').text("EMAIL: "+data.email);
                } //else
            } // success
        }); // ajax
    } // if
    else
    {
        $('div#perfilResult').text("enter username and password");
        $('div#perfilResult').addClass("error");
    } // else
    $('div#perfilResult').fadeIn();
    return false;
}

function borrar(){
    var email = readCookie('k').split("#",1)[0];
    if (email)
    { // values are not empty
        $.ajax({
            type: "GET",              
            url: "cgis/borrarUsuario.cgi", // URL of the Perl script
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data:"email=" + email,
            // script call was *not* successful
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
                $('div#perfilResult').text("responseText: " + XMLHttpRequest.responseText 
                    + ", textStatus: " + textStatus 
                    + ", errorThrown: " +errorThrown);
                $('div#perfilResult').addClass("error");
            }, // error
            // script call was successful
            // data contains the JSON values returned by the Perl script
            success: function(data){
                if (data.error) { // script returned error
                    $('div#perfilResult').text("data.error: "  +data.error);
                    $('div#perfilResult').addClass("error");
                        
                } // if
                else {  // login was successful

                    $('div#perfilResultNombre').text("NOMBRE: "+data.nombre);
                    $('div#perfilResultApellidos').text("APELLIDOS: "+data.apellidos);
                    $('div#perfilResultEmail').text("EMAIL: "+data.email);
                } //else
            } // success
        }); // ajax
        
        eraseCookie('k');
        window.location="index.html";
        
    } // if
    else
    {
        $('div#perfilResult').text("enter username and password");
        $('div#perfilResult').addClass("error");
    } // else
    $('div#perfilResult').fadeIn();
    return false;
    
}
